/*************************************************
 File name : bmpinfo.c
 Create date : 2015-04-15 01:34
 Modified date : 2015-04-15 01:34
 Author : heqingde
 Email : hqd173@163.com
 
 ***********************************************/
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<unistd.h>

int main(void)
{
	//1.打开图片
		int picfd = open("./lijian.bmp", O_RDONLY);

	//2.计算文件大小1
			int len = lseek(picfd, 0, SEEK_END);
			lseek(picfd, 0, SEEK_SET);
	//2.计算文件大小2 文件大小在文件头的第三个字节开始2-4
		int size  = 0;
		lseek(picfd, 2, SEEK_SET);
		read(picfd, &size, 4);
		
	//3.打印
		printf("len = %d\nsize=%d\n", len, size);
		
	//4.取图片尺寸18
		int w, h;
		lseek(picfd, 18, SEEK_SET);
		read(picfd, &w, 4);
		read(picfd, &h, 4);
		
		printf("w = %d\nh=%d\n", w, h);
	//5.图像位深度28
		short bits = 0;
		lseek(picfd, 28, SEEK_SET);
		read(picfd, &bits, 2);
		printf("bits = %d\n", bits);
		return 0;
		
	
}